<%@ page import="com.psl.model.userlogin" %>
<%@page contentType="text/html;" language="java" pageEncoding="UTF-8" %>
<%
    userlogin userinfo = (userlogin) session.getAttribute("user");
    if (userinfo == null) {
        response.sendRedirect("/login.do");
    }
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改密码</title>
    <link href="/assets/css/layout.css" rel="stylesheet" type="text/css">
    <style type="text/css">
        body {
            font-size: 10px;
        }
    </style>
</head>

<body>
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#AEDEF4">
    <tbody>
    <tr>
        <td height="25" colspan="5" align="center" bgcolor="#D6F2FD">修改密码</td>
    </tr>
    <tr>
        <td height="25" colspan="5"><span style="color: #dd3c10">密码修改后将自动返回登录页面重新登录！</span></td>
    </tr>
    <form id="form1" name="form1" method="post" action="/changepw2.do">
        <tr>

            <td height="25" align="center" bgcolor="#FFF9DF" colspan="1">原密码：</td>
            <td colspan="3" bgcolor="#FFF9DF">&nbsp;&nbsp;&nbsp;<input type="text" value="" name="old_pw"></td>
            <td colspan="1" bgcolor="#FFF9DF" rowspan="3" align="center"><input type="submit" value="保存"></td>
        </tr>
        <tr>
            <td height="25" align="center" bgcolor="#FFF9DF" colspan="1">新密码</td>
            <td colspan="3" bgcolor="#FFF9DF">&nbsp;&nbsp;&nbsp;<input type="text" value="" name="password"></td>
        </tr>
        <tr>
            <td height="25" align="center" bgcolor="#FFF9DF" colspan="1">确认密码</td>
            <td colspan="3" bgcolor="#FFF9DF">&nbsp;&nbsp;&nbsp;<input type="text" value="" name="check_password"></td>
        </tr>
        <tr>
            <td colspan="3"><%
                if (request.getAttribute("msg_success") != null) {
                    out.print(request.getAttribute("msg_success"));
                }
            %></td>
        </tr>
    </form>
    </tbody>
</table>
<%--<script>--%>
    <%--function check() {--%>
        <%--var old_pw = document.getElementsByName(old_pw).value;--%>
        <%--var password = document.getElementsByName(password).value;--%>
        <%--var length = document.getElementsByName(password).value.length;--%>
        <%--var checkpassword = document.getElementsByName(checkpassword).value;--%>
        <%--if (old_pw !=<%=userinfo.getpassword()%>) {--%>
            <%--alert('原密码不正确');--%>
            <%--return false;--%>
        <%--}--%>
        <%--if (password ==<%=userinfo.getpassword()%>) {--%>
            <%--alert('新密码不能和原密码相同');--%>
            <%--return false;--%>
        <%--}--%>
        <%--if (checkpassword != password) {--%>
            <%--alert('确认密码和新密码不一致');--%>
            <%--return false;--%>
        <%--}--%>
        <%--if (length < 6) {--%>
            <%--alert('新密码不能少于6位，请重新输入');--%>
            <%--return false;--%>
        <%--}--%>
        <%--else {--%>
            <%--alert('修改成功，请重新登录！');--%>
            <%--document.form1.method = "POST";--%>
            <%--document.form1.action = "/changepw.do";--%>
            <%--document.form1.submit();--%>
        <%--}--%>
    <%--}--%>
<%--</script>--%>
</body>
</html>